package com.lkd.service.impl;

import com.lkd.mapper.TaskMapper;
import com.lkd.service.ReportService;
import com.lkd.service.TaskService;
import com.lkd.vo.TaskVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Service
@RequiredArgsConstructor
public class TaskServiceImpl implements TaskService {
    private final TaskMapper taskMapper;

    //工单统计
    @Override
    public List<TaskVo> taskReportInfo(LocalDateTime start, LocalDateTime end) {
        //生成一个空的vo集合
        List<TaskVo> list = new ArrayList<>();
        //获取工单为运维工单的总数
        Integer total = taskMapper.countType(1, null, start, end);
        //获取工单为运维工单的完成数
        Integer completedTotal = taskMapper.countType(1, 4, start, end);
        //获取工单为运维工单的拒绝总数
        Integer cancelTotal = taskMapper.countType(1, 3, start, end);
        //获取工单为进行中的总数
        Integer progressTotal = taskMapper.countType(1, 2, start, end);
        //获取是否是运维工单
        //获取统计日期
        TaskVo taskVo1 = new TaskVo(total, completedTotal, cancelTotal, progressTotal, 0, true, LocalDateTime.now().toString());
        list.add(taskVo1);


        //获取工单为运营工单的总数
        total = taskMapper.countType(2, null, start, end);
        //获取工单为运营工单的完成数
        completedTotal = taskMapper.countType(2, 4, start, end);
        //获取工单为运营工单的拒绝总数
        cancelTotal = taskMapper.countType(2, 3, start, end);
        //获取工单为进行中的总数
        progressTotal = taskMapper.countType(2, 2, start, end);
        //获取是否是运维工单
        TaskVo taskVo2 = new TaskVo(total, completedTotal, cancelTotal, progressTotal, 0, false, LocalDateTime.now().toString());
        //获取统计日期
        list.add(taskVo2);

        return list;
    }
}
